
<div class="login-box">
  <div class="login-logo">
	<a href="<?=site_url()?>"><b><?=$this->config->item("siteName")?></b></a>
  </div><!-- /.login-logo -->
  <div class="login-box-body">
	<p class="login-box-msg"><?=$this->lang->line("ADMIN")?></p>
	<form action="<?=site_url("admin_lte/login")?>" method="post" autocomplete="off">
	  <div class="form-group has-feedback">
		<input type="text" placeholder="<?=$this->lang->line("E-MAIL_ADDRESS")?>" class="form-control" name="email">
		<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
	  </div>
	  <div class="form-group has-feedback">
		<input type="password" placeholder="<?=$this->lang->line("PASSWORD")?>" class="form-control" name="password">
		<span class="glyphicon glyphicon-lock form-control-feedback"></span>
	  </div>
	  <div class="row">
		<div class="col-xs-8">    
		  <div class="checkbox icheck">
			<label>
			  <input type="checkbox"> <?=$this->lang->line("REMEMBER_ME")?>
			</label>
		  </div>
		</div><!-- /.col -->
		<div class="col-xs-4">
		  <button type="submit" class="btn btn-primary btn-block btn-flat"><?=$this->lang->line("LOGIN")?></button>
		</div><!-- /.col -->
	  </div>
	</form>

	<div class="social-auth-links text-center">
	  <p>- OR -</p>
	  <button onclick="fb_login(); return false;" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> <?=$this->lang->line("SIGN_IN_USING_FACEBOOK")?></button>
	  <a href="<?=site_url()?>openid/google" class="btn btn-block btn-social btn-google-plus btn-flat"><i class="fa fa-google-plus"></i> <?=$this->lang->line("SIGN_IN_USING_GOOGLE")?></a>
	</div><!-- /.social-auth-links -->

  </div><!-- /.login-box-body -->
</div><!-- /.login-box -->

<div id="fb-root"></div>
<script type="text/javascript">
	window.fbAsyncInit = function() {
		FB.init({
			appId   : '<?=$this->config->item("APP_ID")?>',
			channelUrl : '//<?=site_url()?>/channel.html', 
			oauth   : true,
			status  : true, // check login status
			cookie  : true, // enable cookies to allow the server to access the session
			xfbml   : true // parse XFBML
		});
	  };

	function fb_login(){
		FB.login(function(response) {

			if (response.authResponse) {
				//console.log('Welcome!  Fetching your information.... ');
				//console.log(response); // dump complete info
				access_token = response.authResponse.accessToken; //get access token
				user_id = response.authResponse.userID; //get FB UID

				FB.api('/me', function(response) {
					user_email = response.email; //get user email
					// you can store this data into your database             
					$.ajax({type: 'POST', url: '<?=site_url()?>facebook_login', data:'email=' + user_email, beforeSend: function(xhr) {} }).
						always(function() { /*$('#modal').unmask();*/ location.href='<?=site_url()?>';});
				});

			} else {
				//user hit cancel button
				//console.log('User cancelled login or did not fully authorize.');

			}
		}, {
			scope: 'email'
		});
	}
	(function() {
		var e = document.createElement('script');
		e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
		e.async = true;
		document.getElementById('fb-root').appendChild(e);
	}());
</script>

<? return; ?>

<div id="login-box" class="form-box">
	<div class="header"><?=$this->lang->line("LOGIN")?></div>
	<form method="post" action="<?=site_url("admin_lte/login")?>" autocomplete="off">
		<div class="body bg-gray">
			<div class="form-group">
				<input type="text" placeholder="<?=$this->lang->line("E-MAIL_ADDRESS")?>" class="form-control" name="email">
			</div>
			<div class="form-group">
				<input type="password" placeholder="<?=$this->lang->line("PASSWORD")?>" class="form-control" name="password">
			</div>
		</div>
		<div class="footer">
			<button class="btn bg-olive btn-block" type="submit"><?=$this->lang->line("LOGIN")?></button>
		</div>
	</form>

	<div class="margin text-center">
		<button class="btn bg-light-blue btn-circle" type="button" onclick="fb_login(); return false;"><i class="fa fa-facebook"></i></button>
		<button class="btn bg-red btn-circle" type="button" onclick="location.href='<?=site_url()?>openid/google';"><i class="fa fa-google-plus"></i></button>
	</div>
</div>